package mystia.lorelei.app.service;

import jakarta.annotation.Resource;
import mystia.lorelei.app.entity.Activity;
import mystia.lorelei.app.repository.ActivityRepository;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ActivityService {
	@Resource
	private ActivityRepository activityRepository;
	public List<Activity> listActivity(){return activityRepository.findAll();}
	public Activity queryActivity(int id){
		return activityRepository.findById(id).orElse(null);
	}
	public void saveActivity(Activity activity){activityRepository.save(activity);}
	public void deleteActivity(int id){activityRepository.deleteById(id);}
	
	public void deleteActivities(List<Integer> ids){activityRepository.deleteAllByIds(ids);}
	public Activity queryActivityCorrespond(int cuisineId,int requireGrade){
		return activityRepository.findCorrespondActivity(cuisineId, requireGrade);
	}
}
